/* 
 * This script file provides function for asynchronous map api loading
 * 
 */
function loadGmaps(callback){
    var scriptUrl = "http://maps.google.com/maps/api/js?sensor=true&callback=" + callback;
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = scriptUrl;
    $('head').append(script);
}

function loadBingMaps(callback){
    var scriptUrl = "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&onScriptLoad=" + callback;
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = scriptUrl;
    document.head.appendChild(script);
}

function loadSMaps(callback){
    var scriptUrl = "http://beta.api.mapy.cz/loader.js";
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = scriptUrl;
    document.head.appendChild(script);
    if (script.addEventListener){
        script.addEventListener("load", function(){initSMapLoader(callback)}, false);
    } else {
        script.attachEvent("onreadystatechange", initSMapLoader);
    }
}

var initSMapLoader = function(callback){
    Loader.async = true;
    Loader.load(null, null, callback);
}


